﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TWS.Cart.Data;

public partial class Application_Controls_Categories : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Load Categories
        CartCatCategoryCollection ssCategoryColl = new CartCatCategoryCollection()
            .OrderByAsc(CartCatCategory.Columns.CategoryOrder).Load();

		//Load CartConfigVals
	    CartCatConfigurationParameter ssConfigParam = new CartCatConfigurationParameter(2);

        foreach (var catItem in ssCategoryColl)
        {
            TableRow tr = new TableRow();
            TableCell tc0 = new TableCell();
            TableCell tc1 = new TableCell();
            TableCell tc2 = new TableCell();

            tc0.CssClass = "CategoryContentLeft";
            tc1.CssClass = "CategoryContentCenter";
            tc2.CssClass = "CategoryContentRight";

			//HyperLink hl = new HyperLink();
			//hl.Text = catItem.Name;
			//hl.ToolTip = catItem.Description;
			//hl.NavigateUrl = Helper.CreateASPXPage(catItem.Description);//ssConfigParam.ValueX + "?catId=" + catItem.Id;

			//tc1.Controls.Add(hl);
			tc1.Text = "<a href=\"" + Helper.CreateASPXPage(catItem.Description) + "\" title=\"" + catItem.Description +"\" >" + catItem.Name + "</a>";

            tr.Cells.Add(tc0);
            tr.Cells.Add(tc1);
            tr.Cells.Add(tc2);
            TableCategories.Rows.Add(tr);
        }

        //Load the footer.
        TableFooterRow tfr = new TableFooterRow();
        TableCell tcf0 = new TableCell();
        TableCell tcf1 = new TableCell();
        TableCell tcf2 = new TableCell();

        tcf0.CssClass = "CategoryFooterLeft";
        tcf1.CssClass = "CategoryFooterCenter";
        tcf2.CssClass = "CategoryFooterRight";

        tfr.Cells.Add(tcf0);
        tfr.Cells.Add(tcf1);
        tfr.Cells.Add(tcf2);

        TableCategories.Rows.Add(tfr);
    }

    public string Title 
    { 
        get { return LabelHeaderTitle.Text;}
        set { LabelHeaderTitle.Text = value; }
    }
}
